home *** CD-ROM | disk | FTP | other *** search
- /* bt_first.c - position at start/end of index */
- #include "stdio.h"
- #include "btree.h"
- #include "bt_macro.h"
-
- extern IX_DESC *pci ; /* global variable for current pix */
-
- int go_first(pix) /* go to first entry in index */
- IX_DESC *pix ; /* points to an index descriptor */
- {
- BLOCK b ;
-
- pci = pix ;
- /* start at root level and */
- first_ix(pci->dx.nl-1,pci->dx.rb,&b) ; /* set at first entry */
- return( IX_OK ) ;
- }
-
- int first_ix(l,r,pb) /* set curr. pos. to first entry */
- int l ; /* at this and lower levels */
- RECPOS r ; /* curr. block for level l */
- BLOCK *pb ;
- {
- CB(l) = r ; /* set current block */
- CO(l) = 0 ; /* and offset */
- retrieve_block(l,CB(l),pb,CURR) ; /* get the block */
-
- if( l > 0 ) /* set lower levels too */
- first_ix(l-1,ENT_ADR(pb,0)->rptr,pb) ;
- }
-
-
- int go_last(pix) /* go to last index entry (dummy) */
- IX_DESC *pix ; /* points to an index descriptor */
- {
- BLOCK b ;
-
- pci = pix ;
- final_ix(pci->dx.nl-1,pci->dx.rb,&b) ; /* start at root */
- /* position of last entry */
- return( IX_OK ) ; /* success return code */
- }
-
-
- int final_ix(l,r,pb) /* set curr. pos. to first entry */
- int l ; /* at this and lower levels */
- RECPOS r ; /* curr. block for level l */
- BLOCK *pb ;
- {
- int off ;
-
- CB(l) = r ; /* set current block */
- retrieve_block(l,r,pb,CURR) ; /* get the block */
- off = last_entry(pb) ; /* curr. offset = last entry */
- CO(l) = off ;
- if( l > 0 ) /* set lower level too */
- final_ix(l-1,ENT_ADR(pb,off)->rptr,pb) ;
- }
-
-